package hyl.base.mq.rabbit;


import java.util.Properties;

import hyl.core.MyFun;
import hyl.core.conf.MyPrp;

public class RabbitConfig  {

	private static MyPrp _prpp;
	private static MyPrp _prps;
	private static String _brokerAddr = "localhost:9092";
	//private static String _zkAddr = "localhost:9092";
	private static String _groupid = "test";
	
	public static Properties getPrpPub() {
		if(_prpp==null) {
		 _prpp =new  MyPrp ("mq/kafka_pub.conf");
		 _prpp.set("host",_brokerAddr);
		}
		 return  _prpp.getAll();
	}

	public static Properties getPrpSub() {
		if(_prps==null) {
			_prps =new  MyPrp ("kafka_sub.conf");			
		_prps.set("bootstrap.servers", "localhost:9092");		
		// 消费者所在组
		_prps.set("group.id", _groupid);
		// zk连接超时
//		_prps.set("zookeeper.connect", _zkAddr);
//		_prps.set("zookeeper.session.timeout.ms", "4000");
//		_prps.set("zookeeper.sync.time.ms", "200");	
	//	_prps.set("auto.offset.set", "smallest");
		//是否自动提交
		_prps.set("enable.auto.commit", "false");
		
		isautocommit= MyFun.str2Bool(_prps.get("enable.auto.commit"));
		//_prps.set("auto.commit.interval.ms", "1000");
		_prps.set("session.timeout.ms", "30000");
		// 序列化类
		_prps.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
		_prps.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
		//_prps.set("serializer.class", "kafka.serializer.StringEncoder");
	
		}
	 
		return  _prps.getAll();
	}
	/**是否自动提交*/
  private static	boolean isautocommit=true;
	/**是否自动提交*/
	public static boolean isAutoCommit() {
		return isautocommit;
	}

}
